package com.kamkor.interviewer.client.security;

import com.google.gwt.user.client.rpc.AsyncCallback;
import com.kamkor.interviewer.client.InterviewServiceAsync;
import com.kamkor.interviewer.client.presenter.SecurePresenter;

public class InterviewedAuthentication extends Authentication {	
	public InterviewedAuthentication(InterviewServiceAsync service) {
		super(service);	
	}

	@Override
	public void authenticate(Long interviewId, Long key, final SecurePresenter presenter) {
		getService().authenticateInterviewed(interviewId, key, new AsyncCallback<Boolean>() {			
			@Override
			public void onSuccess(Boolean result) {
				if(result) {
					presenter.authenticationSucceeded();
				} else {
					presenter.authenticationFailed();
				}
			}
			
			@Override
			public void onFailure(Throwable caught) {
				presenter.authenticationFailed();				
			}
		});
	}

}
